// DELETE => /api/articles/:id
import {NextResponse} from "next/server";
import db from "@/db";

export async function DELETE(request: Request, { params }: { params: { id: string } }) {
    await db.update(({posts}) => {
        const index = posts.findIndex(post => post.id === params.id);
        posts.splice(index, 1);
    })
    return NextResponse.json({
        code: 200,
        message: "success",
        data: params.id
    });
}

// PATCH => /api/articles/:id
export async function PATCH(request: Request) {}

// GET => /api/articles/:id
export async function GET(request: Request) {}
